import { http } from "@/utils/http";
import { baseUrlApi, filerEmptyVal } from "../utils";

/** 获取基础档案-仓库管理列表 */
export const getDepositoryPage = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/depository/page"), {
    params: filerEmptyVal(params)
  });
};

/** 获取基础档案-仓库管理列表 */
export const getDepositorySimplePage = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/depository/simple/page"), {
    params: filerEmptyVal(params)
  });
};

/** 基础档案-仓库管理列表-新增仓库 */
export const depositoryAdd = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/depository/add"), { data });
};

/** 基础档案-仓库管理列表-编辑仓库 */
export const depositoryUpdate = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/depository/update"), { data });
};

/** 基础档案-仓库管理列表-删除仓库 */
export const depositoryDelete = (id?: object) => {
  return http.request<any>("post", baseUrlApi(`/depository/delete?id=${id}`));
};

/** 获取基础档案-仓库管理列表详情 */
export const getDepositoryDetail = (params?: object) => {
  return http.request<any>("get", baseUrlApi("/depository/detail"), { params });
};

/** 基础档案-仓库管理列表-状态启用禁用 */
export const depositoryChangeStatus = (data?: object) => {
  return http.request<any>("post", baseUrlApi("/depository/change/status"), {
    data
  });
};

/** 导入仓库列表 */
export const importdepos = (data?: any) => {
  return http.request<any>(
    "post",
    `/erpPlatApi/depository/import/depositories`,
    {
      data,
      params: {
        isShowErrTips: false
      }
    },
    {
      headers: {
        "Content-Type": "multipart/form-data"
      }
    }
  );
};

/** 导出仓库列表 */
export const exportDepos = (params?: any) => {
  return http.request<any>(
    "get",
    `/erpPlatApi/depository/export/depositories`,
    { params: filerEmptyVal(params) },
    { responseType: "blob" }
  );
};
